package com.api;


import com.api.Fallback.ItemClientFallback;
import com.dto.ItemDTO;
import com.dto.OrderDetailDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

/**
 * @author: LiuLi
 * @Date: 2025/09/03 11:55
 * @Description:
 */
@FeignClient(name="item-service",fallbackFactory = ItemClientFallback.class)
public interface ItemClient {
    /**
     * 根据商品id列表查询商品信息
     * @param ids 商品id列表
     * @return 商品信息列表
     */
    @GetMapping("/items")
    List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids);

    /**
     * 批量扣减库存
     * @param items 订单详情列表
     */
    @PutMapping("/stock/deduct")
    void deductStock(@RequestBody List<OrderDetailDTO> items);
}
